#!/bin/bash

echo '设置权限'
mkdir -p ./volume/rmq/nameserv/logs
mkdir -p ./volume/rmq/broker/{logs,store}

chown -R 3000:3000 ./volume

# 主机ip
ip=$(ip addr | grep ens | awk -F ' ' 'NR==2{print $2}' | awk -F '/' '{print $1}')

echo "修改配置文件 主机ip为:$ip"
sed -i -e "/^brokerIP1/c brokerIP1 = $ip" \
  -e "/^brokerIP2/c brokerIP2 = $ip" \
  ./init/rmq/broker.conf


echo '开放端口'
firewall-cmd --zone=public --add-port=9876/tcp --permanent

firewall-cmd --zone=public --add-port=10909/tcp --permanent
firewall-cmd --zone=public --add-port=10911/tcp --permanent

firewall-cmd --zone=public --add-port=8180/tcp --permanent

firewall-cmd --reload

echo '启动容器'
docker-compose up -d

echo '查看容器'
docker-compose ps
